package com.bjpowernode.javase.annotation6;

import java.lang.reflect.Method;

public class MyAnnotationTest {
    @MyAnnotation(userName = "sunxueteng",password = "521")
    public void doSome(){

    }
    public static void main(String[] args) throws Exception  {
        //获取这个类的doSome()方法的注解的属性
        Class c = Class.forName("com.bjpowernode.javase.annotation6.MyAnnotationTest");
        //获取方法
        Method doSomeMethod = c.getDeclaredMethod("doSome");
        //判断改方法上是否存在改注解
        if(doSomeMethod.isAnnotationPresent(MyAnnotation.class)){
            MyAnnotation myAnnotation = doSomeMethod.getAnnotation(MyAnnotation.class);
            System.out.println(myAnnotation.userName());
            System.out.println(myAnnotation.password());
        }
    }
}
